#include<iostream>
#include<string>
using namespace std;
int n,i,j,ans;
string s;
char get(int x)
{
	if(x<n) return s[x];
	else return s[x-n];
}
int main()
{
	cin>>s;
	n=s.size();
	ans=0;
	for(i=1;i<=n-1;i++)
	{
		printf("i == %d\n",i);
		for(j=0;j<=n-1;j++)
		{
			printf("\t j == %d\n",j);
			printf("\t\t get(i+j)==%c get(ans+j)==%c\n",get(i+j),get(ans+j));
			if(get(i+j)<get(ans+j))
			{
				printf("\t\t%c < %c\n",get(i+j),get(ans+j));
				printf("\t\tans = %d\n",i);
				printf("\t\tbreak;\n");
				ans=i;
				break;
			}
			else if(get(i+j)>get(ans+j)) 
			{
				printf("\t\t %c > %c\n",get(i+j),get(ans+j));
				printf("\t\tbreak;\n");
				break;
			}
		}
	}
	for(j=0;j<=n-1;j++) cout<<get(ans+j);
	cout<<endl;
	return 0;
}
